<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>生成业务表列表</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form action="gentable/dolist" method="post" name="searchForm" id="searchForm" role="form" class="form-horizontal">


        <div class="form-group">
            <label class="col-sm-1 control-label">项目：</label>
            <div class="col-md-4">
                <d:select clazz="selectpicker" list="${genProjects}" name="projectId" selected="${searchEntity.projectId}" ></d:select>
            </div>
            <label class="col-sm-1 control-label">表名：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="tableName" value="${searchEntity.tableName}" placeholder="表名">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-1 control-label">关键字：</label>
            <div class="col-md-4">
                <div class="input-group">
                    <input type="text" class="form-control" name="keywords" value="${searchEntity.keywords}" placeholder="表、模块">
                    <div class="input-group-btn">
                        <button id="searchBtn" type="button" class="btn btn-sm btn-info"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>

            </div>
        </div>
    </form>
    <div class="row">
        <div class="col-md-10">
            <p>
                <shiro:hasPermission name="gentable:add">
                    <button type="button" data-url="gentable/create" class="btn btn-sm btn-success link_add" data-title="新增生成业务表"><i class="fa fa-plus"></i> 新增</button>
                </shiro:hasPermission>
                <shiro:hasPermission name="gentable:edit">
                    <button type="button" data-url="gentable/edit" class="btn btn-sm btn-primary link_edit" data-title="编辑生成业务表"><i class="fa fa-edit"></i> 修改</button>
                </shiro:hasPermission>
                <shiro:hasPermission name="gentable:delete">
                    <button type="button" data-url="gentable/delete" class="btn btn-sm btn-danger link_del"><i class="fa fa-trash"></i> 删除</button>
                </shiro:hasPermission>
                <shiro:hasPermission name="gentable:view">
                    <button type="button" data-url="gentable/info" class="btn btn-sm link_info" data-title="生成业务表详情"><i class="fa fa-book"></i> 详情</button>
                </shiro:hasPermission>
                <button id="genCodeBtn" type="button" class="btn btn-sm btn-primary" data-title="生成并下载代码"><i class="fa fa-file-code-o"></i> 生成并下载代码</button>
            </p>
        </div>
    </div>

    <table id="table_data" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center td-checkbox" width="5%">
                <label><input type="checkbox" class="check-all ace" data-tableid="table_data" /><span class="lbl"></span></label>
            </th>
            <th width="10%">项目</th>
            <th width="10%">模块名</th>
            <th width="10%">模块包名</th>
            <th width="10%">表名</th>
            <th width="10%">功能名</th>
            <th width="5%">列数</th>
            <th width="10%">代码作者</th>
            <th width="10%">代码版本</th>
            <th width="5%">已配置</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        $('#genCodeBtn').click(function(){
            var arr = $('.data-item:checked');
            var ids = getCheckedValues(arr, {required:true});

            top.loading('正在生成源代码，请稍等');
            $.ajax({
                url: "gentable/genCode",
                type: "POST",
                data:{ids:ids.join(',')},
                dataType: "json",
                success: function (res) {
                    top.loaded();
                    if(res.success && res.data.id){
                        location.href="common/download/"+res.data.id;
                    }
                }
            });
        });

        var table = $("#table_data").dataTable({
            ajax: function(data, callback, settings){
                tableAjax($("#searchForm"),data, callback, settings);
            },
            //列表表头字段
            columns: [
                mainConfig.checkboxColumn,
                { "data": "projectName",name:"project_id" },
                { "data": "moduleName",name:"module_name" },
                { "data": "modulePackage",name:"module_package" },
                { "data": "tableName",name:"table_name" },
                { "data": "functionName",name:"function_name" },
                { "data": "columnNum",name:"column_num" },
                { "data": "codeAuthor",name:"code_author" },
                { "data": "codeVersion",name:"code_version" },
                { "data": "isConfigStr" }
        ]
    }).api();

        //查询条件
        $("#searchForm").submit(function(){
            table.ajax.reload();
            return false;
        });
    });
</script>
<!-- script end -->
</body>
</html>